// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill'
import Vue from 'vue'
import App from './App'
// import axios from 'axios'
import http from './assets/js/http'
import router from './router'
import store from './store'
import * as filters from './assets/js/filters'
import { AlertPlugin, ToastPlugin } from 'vux'
import { Scroll, ScrollNavBar } from 'cube-ui'
import 'cube-ui/lib/scroll/style.css'

Vue.prototype.$http = http
Vue.use(AlertPlugin)
Vue.use(ToastPlugin)
Vue.use(Scroll)
Vue.use(ScrollNavBar)
Vue.config.productionTip = false
Object.keys(filters).forEach(key => Vue.filter(key, filters[key]))

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>',
  created () {
    (function (doc, win) {
      var docEl = doc.documentElement
      var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
      var recalc = function () {
        var clientWidth = docEl.clientWidth
        if (!clientWidth) {
          return
        }
        if (clientWidth > 540) {
          //        docEl.style.fontSize = '72px'
          docEl.style.cssText += 'font-size: 72px !important;'
        } else {
          //        docEl.style.fontSize = 100 * (clientWidth / 750) + 'px'
          docEl.style.cssText += 'font-size: ' + (100 * (clientWidth / 750)) + 'px !important;'
        }
      }
      if (!doc.addEventListener) {
        return
      }
      win.addEventListener(resizeEvt, recalc, false)
      doc.addEventListener('DOMContentLoaded', recalc, false)
    })(document, window)
  }
})
